import Icon from '@/components/Icon'
import styled from 'styled-components'

export const Wrap = styled.div`
	height: 100%;
	.list-title {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 14px;
		color: #4e4e4e;
		border-bottom: 1px solid #9a9a9a;
		margin-bottom: 10px;
		.add-btn {
			font-size: 12px;
			color: #3e9bd0;
			cursor: pointer;
		}
	}
	.list-tab {
		margin-bottom: 10px;
	}
	.tabs {
		width: 287px;
	}
	.list-actions {
		display: flex;
		&__menu {
			margin-left: 10px;
			flex: 0 0 30px;
		}
		.list-search {
			margin-top: 2px;
		}
	}
`

export const IconMenu = styled(Icon)`
	width: 30px;
	height: 30px;
	background-position: -120px -1569px;
`

export const StyledMenuWrap = styled.div`
	width: 30px;
	height: 30px;
	font-size: 12px;
	ul.menu {
		width: 128px;
		padding: 5px 0;
		border: 1px solid #dadada;
		color: #4e4e4e;
		position: absolute;
		top: 32px;
		right: 0px;
		background: #fff;
		z-index: 2;
		cursor: pointer;
		border-radius: 6px;
		li {
			padding: 0 15px;
			line-height: 32px;
			&:hover {
				background: #1e94da;
				color: #fff;
			}
		}
	}
`

interface ItemWrapProps {
	readonly checked: boolean
	readonly indexWidth?: number
	readonly nestingLevel?: number
}
export const ItemWrap = styled.div.attrs((props: ItemWrapProps) => ({
	className: props.checked ? 'checked' : '',
}))<ItemWrapProps>`
	height: 38px;
	margin: 2px 0;
	user-select: none;
	cursor: pointer;
	position: relative;
	box-sizing: border-box;
	display: flex;
	&:hover {
		color: #fff;
		background: url()
			no-repeat #5eb9ef;
		background: linear-gradient(90deg, #2d8bc0, #53afe4);
		.icon-checkbox {
			background-position: -237px -1672px;
		}
	}
	&.checked,
	&.checked:hover {
		color: #fff;
		background: url()
			no-repeat #5eb9ef;
		background: linear-gradient(90deg, #2d8bc0, #53afe4);
		.icon-checkbox {
			background-position: -93px -1672px;
		}
	}
	padding-left: ${(props) => {
		if (props.nestingLevel) {
			return props.nestingLevel * 30 + 'px'
		}
		return 0
	}};
	.left-wrap {
		flex: 0 0 26px;
		height: 38px;
		text-align: center;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.avatar {
		flex: 0 0 32px;
		height: 38px;
		position: relative;
		display: flex;
		justify-content: center;
		align-items: center;
		&.avatar-ghost {
			margin-left: 10px;
		}
		&--often {
			position: absolute;
			bottom: 4px;
			right: 2px;
		}
	}
	.name {
		flex: 1;
		padding-left: 10px;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		height: 38px;
		line-height: 38px;
	}
	.right-icons {
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.set-often {
		margin-right: 4px;
	}
	.remove {
		margin-right: 6px;
	}
`

export const IconCheckbox = styled(Icon)`
	width: 12px;
	height: 12px;
	background-position: -3px -1672px;
`
export const IconRemove = styled(Icon)`
	width: 13px;
	height: 13px;
	background-position: -77px -249px;
	&:hover {
		background-position: -91px -249px;
	}
`
export const IconOftenInAvatar = styled(Icon)`
	width: 11px;
	height: 11px;
	background-position: 0 -1767px;
`
export const IconToggleAdd = styled(Icon)`
	width: 13px;
	height: 13px;
	background-position: -273px -249px;
`
export const IconToggleCancel = styled(Icon)`
	width: 13px;
	height: 13px;
	background-position: -338px -249px;
`
export const IconTreeRightArrow = styled(Icon)`
	width: 12px;
	height: 12px;
	background-position: -56px -1085px;
`
export const IconTreeDownArrow = styled(Icon)`
	width: 12px;
	height: 12px;
	background-position: 0px -1085px;
`
